home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / hack / 3_1 / sys / vms / vmsbuild.com < prev    next >
Encoding:
Text File  |  1993-01-08  |  11.1 KB  |  281 lines

  1. $ ! vms/vmsbuild.com -- compile and link NetHack 3.1 patchlevel 0    [pr]
  2. $ !
  3. $ ! usage:
  4. $ !   $ set default [.src]    !or [-.-.src] if starting from [.sys.vms]
  5. $ !   $ @[-.sys.vms]vmsbuild  [compiler-option]  [link-option]  [cc-switches]
  6. $ ! options:
  7. $ !    compiler-option :  either "VAXC" or "GNUC" or ""    !default VAXC
  8. $ !    link-option    :  either "SHARE[able]" or "LIB[rary]"    !default SHARE
  9. $ !    cc-switches    :  optional qualifiers for CC (such as "/noOpt/Debug")
  10. $ ! notes:
  11. $ !    If the symbol "CC" is defined, compiler-option is not used.
  12. $ !    The link-option refers to VAXCRTL (C Run-Time Library) handling;
  13. $ !      to specify it while letting compiler-option default, use "" as
  14. $ !      the compiler-option.
  15. $ !    To re-link without compiling, use "LINK" as special 'compiler-option';
  16. $ !      to re-link with GNUC library, 'CC' must begin with "G" (or "g").
  17. $ !    Default wizard definition moved to include/vmsconf.h.
  18. $
  19. $    vaxc_ = "CC/NOLIST/OPTIMIZE=NOINLINE"        !vaxc v3.x (2.x fixed below)
  20. $    gnuc_ = "GCC"
  21. $    gnulib = "gnu_cc:[000000]gcclib/Library"    !(not used w/ vaxc)
  22. $ ! common CC options (/obj=file doesn't work for GCC 1.36, use rename instead)
  23. $    c_c_  = "/INCLUDE=[-.INCLUDE]"
  24. $    veryold_vms = f$extract(1,1,f$getsyi("VERSION")).eqs."4" -
  25.         .and. f$extract(3,3,f$getsyi("VERSION")).lts."6"
  26. $    if veryold_vms then  c_c_ = c_c_ + "/DEFINE=(""VERYOLD_VMS"")"
  27. $ ! miscellaneous setup
  28. $    ivqual = %x00038240    !DCL-W-IVQUAL (used to check for ancient vaxc)
  29. $    abort := exit %x1000002A
  30. $    cur_dir  = f$environment("DEFAULT")
  31. $    vmsbuild = f$environment("PROCEDURE")
  32. $ ! validate first parameter
  33. $    p1 := 'p1'
  34. $    o_VAXC = 0    !(c_opt substring positions)
  35. $    o_GNUC = 5
  36. $    o_LINK = 10
  37. $    o_SPCL = 15
  38. $    c_opt = f$locate("|"+p1, "|VAXC|GNUC|LINK|SPECIAL|") !5
  39. $     if (c_opt/5)*5 .eq. c_opt then  goto p1_ok
  40. $    copy sys$input: sys$error:    !p1 usage
  41. %first arg is compiler option; it must be one of
  42.        "VAXC" -- use VAX C to compile everything
  43.    or  "GNUC" -- use GNU C to compile everything
  44.    or  "LINK" -- skip compilation, just relink nethack.exe
  45.    or  "SPEC[IAL]" -- just compile and link lev_comp.exe
  46.    or    ""   -- default operation (VAXC unless 'CC' is defined)
  47.  
  48. Note: if a DCL symbol for CC is defined, "VAXC" and "GNUC" are no-ops.
  49.       If the symbol value begins with "G" (or "g"), then the GNU C
  50.       library will be included in all link operations.  Do not rebuild
  51.       lev_comp with "SPECIAL" unless you have a CC symbol setup with
  52.       the proper options.
  53. $    abort
  54. $p1_ok:
  55. $ ! validate second parameter
  56. $    p2 := 'p2'
  57. $    l_opt = f$locate("|"+p2, "|SHAREABLE|LIBRARY__|") !10
  58. $     if (l_opt/10)*10 .eq. l_opt then    goto p2_ok
  59. $    copy sys$input: sys$error:    !p2 usage
  60. %second arg is VAXCRTL handling; it must be one of
  61.        "SHAREABLE" -- link with SYS$SHARE:VAXCRTL.EXE/SHAREABLE
  62.    or   "LIBRARY"  -- link with SYS$LIBRARY:VAXCRTL.OLB/LIBRARY
  63.    or      ""      -- default operation (use shareable image)
  64.  
  65. Note: for MicroVMS 4.x, "SHAREABLE" (which is the default) is required.
  66. $    abort
  67. $p2_ok:
  68. $ ! start from a known location -- [.sys.vms], then move to [-.-.src]
  69. $    set default 'f$parse(vmsbuild,,,"DIRECTORY")'
  70. $    set default [-.-.src]    !move to source directory
  71. $ ! compiler setup; if a symbol for "CC" is already defined it will be used
  72. $     if f$type(cc).eqs."STRING" then  goto got_cc
  73. $    cc = vaxc_            !assume "VAXC" requested or defaulted
  74. $    if c_opt.eq.o_GNUC then  goto chk_gcc !explicitly invoked w/ "GNUC" option
  75. $    if c_opt.ne.o_VAXC then  goto got_cc !"SPEC" or "LINK", skip compiler check
  76. $    ! we want to prevent function inlining with vaxc v3.x (/opt=noinline)
  77. $    !   but we can't use noInline with v2.x, so need to determine version
  78. $      set noOn
  79. $      msgenv = f$environment("MESSAGE")
  80. $      set message/noFacil/noSever/noIdent/noText
  81. $      cc/noObject _NLA0:/Include=[]     !strip 'noinline' if error
  82. $      sts = $status
  83. $    if sts then  goto reset_msg    !3.0 or later will check out OK
  84. $    ! must be dealing with vaxc 2.x; ancient version (2.2 or earlier)
  85. $    !   can't handle /include='dir', needs c$include instead
  86. $      cc = cc - "=NOINLINE" - ",NOINLINE" - "NOINLINE,"
  87. $      if sts.ne.IVQUAL then  goto reset_msg
  88. $        define/noLog c$include [-.INCLUDE]
  89. $        c_c_ = "/DEFINE=(""ANCIENT_VAXC"")"
  90. $        if veryold_vms then  c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
  91. $reset_msg:
  92. $      set message 'msgenv'
  93. $      set On
  94. $      goto got_cc
  95. $ !
  96. $chk_gcc:
  97. $    cc = gnuc_
  98. $ ! old versions of gcc-vms don't have <varargs.h> or <stdarg.h> available
  99. $      c_c_ = "/DEFINE=(""USE_OLDARGS"")"
  100. $      if veryold_vms then  c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
  101. $      if veryold_vms then  goto chk_gas    !avoid varargs & stdarg
  102. $      if f$search("gnu_cc_include:[000000]varargs.h").nes."" then -
  103.         c_c_ = "/DEFINE=(""USE_VARARGS"")"
  104. $      if f$search("gnu_cc_include:[000000]stdarg.h").nes."" then -
  105.         c_c_ = "/DEFINE=(""USE_STDARG"")"
  106. $chk_gas:
  107. $ ! test whether this version of gas handles the 'const' construct correctly
  108. $ gas_chk_tmp = "sys$scratch:gcc-gas-chk.tmp"
  109. $ if f$search(gas_chk_tmp).nes."" then  delete/noconfirm/nolog 'gas_chk_tmp';*
  110. $ gas_ok = 0    !assume bad
  111. $ on warning then goto skip_gas
  112. $ define/user/nolog sys$error 'gas_chk_tmp'
  113. $ mcr gnu_cc:[000000]gcc-as sys$input: -o _NLA0:
  114. $DECK
  115. .const
  116. .comm dummy,0
  117. .const
  118. .comm dummy,0
  119. $EOD
  120. $ gas_ok = 1    !assume good
  121. $ if f$search(gas_chk_tmp).eqs."" then  goto skip_gas
  122. $ ! if the error file is empty, gas can deal properly with const
  123. $  gas_ok = f$file_attrib(gas_chk_tmp,"EOF") .eq. 0
  124. $  delete/noconfirm/nolog 'gas_chk_tmp';*
  125. $skip_gas:
  126. $ on warning then continue
  127. $      if .not.gas_ok then  c_c_ = c_c_ - ")" + ",""const="")"
  128. $      c_c_ = "/INCLUDE=[-.INCLUDE]" + c_c_
  129. $ !
  130. $got_cc:
  131. $    cc = cc + c_c_            !append common qualifiers
  132. $    if p3.nes."" then  cc = cc + p3 !append optional user preferences
  133. $    g := 'f$extract(0,1,cc)'
  134. $    if g.nes."G" .and. c_opt.ne.o_GNUC then  gnulib = ""
  135. $    if g.eqs."G"  .or. c_opt.eq.o_GNUC then  gnulib = "," + gnulib
  136. $ ! linker setup; if a symbol for "LINK" is defined, we'll use it
  137. $    if f$type(link).nes."STRING" then  link = "LINK/NOMAP"
  138. $    if p4.nes."" then  link = link + p4 !append optional user preferences
  139. $    crtl = "sys$library:vaxcrtl.olb/Library"    !object library
  140. $     if l_opt.ne.0 then  goto crtl_ok
  141. $    crtl = "sys$disk:[-.src]crtl.opt/Options"    !shareable image
  142. $     if f$search("crtl.opt").nes."" then  goto crtl_ok !assume its right
  143. $    create sys$disk:[-.src]crtl.opt
  144. sys$share:vaxcrtl.exe/Shareable
  145. $crtl_ok:
  146. $ ! final setup
  147. $    nethacklib = "[-.src]nethack.olb"
  148. $    milestone = "write sys$output f$fao("" !5%T "",0),"
  149. $     if c_opt.eq.o_LINK then  goto link  !"LINK" requested, skip compilation
  150. $    rename     := rename/New_Vers
  151. $    touch     := set file/Truncate
  152. $    makedefs := $sys$disk:[-.util]makedefs
  153. $    show symbol cc
  154. $    goto begin    !skip subroutines
  155. $!
  156. $compile_file:    !input via 'c_file'
  157. $    no_lib = ( f$extract(0,1,c_file) .eqs. "#" )
  158. $    if no_lib then    c_file = f$extract(1,255,c_file)
  159. $    c_name = f$edit(f$parse(c_file,,,"NAME"),"LOWERCASE")
  160. $    f_opts = ""    !options for this file
  161. $    if f$type('c_name'_options).nes."" then  f_opts = 'c_name'_options
  162. $    milestone " (",c_name,")"
  163. $    if f$search("''c_name'.obj").nes."" then  delete 'c_name'.obj;*
  164. $    cc 'f_opts' 'c_file'.c
  165. $    if .not.no_lib then  nh_obj_list == nh_obj_list + ",''c_name'.obj;0"
  166. $     return
  167. $!
  168. $compile_list:    !input via 'c_list'
  169. $    nh_obj_list == ""
  170. $    j = -1
  171. $ c_loop:
  172. $    j = j + 1
  173. $    c_file = f$element(j,",",c_list)  !get next file
  174. $    if c_file.nes."," then    gosub compile_file
  175. $    if c_file.nes."," then    goto c_loop
  176. $    nh_obj_list == f$extract(1,999,nh_obj_list)
  177. $    if nh_obj_list.nes."" then  libr/Obj 'nethacklib' 'nh_obj_list'/Replace
  178. $    if nh_obj_list.nes."" then  delete 'nh_obj_list'
  179. $    delete/symbol/global nh_obj_list
  180. $     return
  181. $!
  182. $begin:
  183. $!
  184. $! miscellaneous special source file setup
  185. $!
  186. $ if f$search("monst.c").eqs."" then  copy/Concat monst.c1+.c2 monst.c
  187. $ if f$search("random.c").eqs."" then  copy [-.sys.share]random.c []*.*
  188. $ if f$search("[-.util]lev_yacc.c").eqs."" then  @[-.sys.vms]spec_lev.com
  189. $!
  190. $! create object library
  191. $!
  192. $ libr/Obj 'nethacklib'/Create=(Block=3000,Hist=0)
  193. $ if f$search("''nethacklib';-1").nes."" then  purge 'nethacklib'
  194. $!
  195. $! compile and link makedefs, then nethack, finally lev_comp & dgn_comp.
  196. $!
  197. $ milestone "<compiling...>"
  198. $ c_list = "[-.sys.vms]vmsmisc,[]alloc,monst,objects"
  199. $     if c_opt.eq.o_SPCL then  c_list = c_list + ",decl,drawing"
  200. $ gosub compile_list
  201. $     if c_opt.eq.o_SPCL then  goto special !"SPECIAL" requested, skip main build
  202. $ set default [-.util]
  203. $ c_list = "#makedefs"
  204. $ gosub compile_list
  205. $ link makedefs.obj,'nethacklib'/Lib,'crtl''gnulib',sys$input:/Opt
  206. identification="makedefs 3.1.0"
  207. $ milestone "makedefs"
  208. $! create some build-time files
  209. $ makedefs -p    !pm.h
  210. $ makedefs -o    !onames.h
  211. $ makedefs -v    !date.h
  212. $ milestone " (*.h)"
  213. $ makedefs -m    !../src/monstr.c
  214. $ makedefs -z    !../src/vis_tab.c, ../include/vis_tab.h
  215. $ milestone " (*.c)"
  216. $ set default [-.src]
  217. $! compile most of the source files:
  218. $    gnutermcap_options = "/Define=(""bcopy(s,d,n)=memcpy(d,s,n)"",""exit=vms_exit"")"
  219. $    if c_opt.eq.o_GNUC then  gnutermcap_options = "/Define=(""exit=vms_exit"")"  !gcc
  220. $ c_list = "decl,version,[-.sys.vms]vmsmain,[-.sys.vms]vmsunix" -
  221.     + ",[-.sys.vms]vmstty,[-.sys.vms]vmsmail,[-.sys.vms]vmsfiles" -
  222.     + ",[]random"    !copied from [-.sys.share]
  223. $ gosub compile_list
  224. $ c_list = "[-.win.tty]getline,[-.win.tty]termcap" -
  225.     + ",[-.win.tty]topl,[-.win.tty]wintty" -
  226.     + ",[-.sys.vms]gnutparam,[-.sys.vms]gnutermcap"
  227. $ gosub compile_list
  228. $ c_list = "allmain,apply,artifact,attrib,ball,bones,botl,cmd,dbridge,detect" -
  229.     + ",display,do,do_name,do_wear,dog,dogmove,dokick,dothrow,drawing" -
  230.     + ",dungeon,eat,end,engrave,exper,explode,extralev,files,fountain"
  231. $ gosub compile_list
  232. $ c_list = "hack,hacklib,invent,lock,mail,makemon,mcastu,mhitm,mhitu" -
  233.     + ",minion,mklev,mkmap,mkmaze,mkobj,mkroom,mon,mondata,monmove,monstr" -
  234.     + ",mplayer,mthrowu,muse,music,o_init,objnam,options,pager,pickup"
  235. $ gosub compile_list
  236. $ c_list = "pline,polyself,potion,pray,priest,quest,questpgr,read" -
  237.     + ",rect,restore,rip,rnd,rumors,save,shk,shknam,sit,sounds" -
  238.     + ",sp_lev,spell,steal,timeout,topten,track,trap,u_init"
  239. $ gosub compile_list
  240. $ c_list = "uhitm,vault,vision,vis_tab,weapon,were,wield,windows" -
  241.     + ",wizard,worm,worn,write,zap"
  242. $ gosub compile_list
  243. $!
  244. $link:
  245. $ milestone "<linking...>"
  246. $ link/Exe=nethack 'nethacklib'/Lib/Incl=(vmsmain),'crtl''gnulib',-
  247.     sys$input:/Opt
  248. identification="NetHack 3.1.0"
  249. $ milestone "NetHack"
  250. $     if c_opt.eq.o_LINK then  goto done    !"LINK" only
  251. $special:
  252. $!
  253. $! build special level and dungeon compilers
  254. $!
  255. $ set default [-.util]
  256. $ c_list = "#panic,#lev_main,#lev_yacc,#dgn_main,#dgn_yacc"
  257. $     if c_opt.eq.o_SPCL then  c_list = "[-.sys.vms]vmsfiles," + c_list
  258. $ gosub compile_list
  259. $ c_list = "#lev_lex,#dgn_lex"
  260. $ copy [-.sys.vms]lev_lex.h stdio.*/Prot=(s:rwd,o:rwd)
  261. $ gosub compile_list
  262. $ rename stdio.h lev_lex.*
  263. $ link/exe=lev_comp lev_main,lev_yacc,lev_lex,-
  264.     panic.obj,'nethacklib'/Lib,'crtl''gnulib',sys$input:/Opt
  265. identification="lev_comp 3.1.0"
  266. $ milestone "lev_comp"
  267. $ link/exe=dgn_comp dgn_main,dgn_yacc,dgn_lex,-
  268.     panic.obj,'nethacklib'/Lib,'crtl''gnulib',sys$input:/Opt
  269. identification="dgn_comp 3.1.0"
  270. $ milestone "dgn_comp"
  271. $!
  272. $ c_list = "#recover"
  273. $ gosub compile_list
  274. $ link/exe=[] recover.obj,'nethacklib'/Lib,'crtl''gnulib',sys$input:/Opt
  275. identification="recover 3.1.0"
  276. $ milestone "recover"
  277. $!
  278. $done:
  279. $    set default 'cur_dir'
  280. $ exit
  281.